﻿using System.ComponentModel;

namespace NTTDATA.BEENChina.ResultCertification.PropertyGridUtil.CustomObject
{
    [TypeConverter(typeof(ElementSettingTypeConverter))]    
    public class ElementSetting : PropertyData
    {
        private int _row = -1;
        private int _col = -1;
        private int _startindex = -1;
        private int _length = -1;

        [Category("条件-位置")]
        public int Row
        {
            get { return _row; }
            set { _row = value; }
        }

        [Category("条件-位置")]
        public int Col
        {
            get { return _col; }
            set { _col = value; }
        }

        [Category("条件-A")]
        public int Startindex
        {
            get { return _startindex; }
            set { _startindex = value; }
        }
        [Category("条件-A")]
        public int Length
        {
            get { return _length; }
            set { _length = value; } 
        }

        //true: substring字符串 在values
        //false substring字符串 不在values
        private bool _contains = true;
        [Category("条件-A")]
        public bool Contains { 
            get { return _contains; }
            set { _contains = value; }
        }

        private string[] values = new string[0];
        [Category("条件-A")]
        public string[] Values
        {
            get { return values; }
            set { values = value; }
        }



        //录入结果字符总长度
        [Category("条件-B")]
        public int ResultLength { get; set; }


        #region PropertyData impl
        public  string GetDisplayName()
        {
            return this.Startindex + ";" + this.Length + ";[" + string.Join(",", this.Values) + "]";
        }
        public  string GetDescription()
        {
            return "description";
        }
        public  string GetValue()
        {
            return this.Startindex + ";" + this.Length + ";[" + string.Join(",", this.Values) + "]";
        }
        #endregion
    }

    [TypeConverter(typeof(CustomConverter))]
    public class Conditinon : PropertyData
    {
        private ElementSetting preCnditions = new ElementSetting();

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("前置条件")]
        public ElementSetting PreCnditions 
        {
            get { return preCnditions; }
            set { preCnditions = value; }
        }

        private CustomCollection<ElementSetting> _elementSettings 
            = new CustomCollection<ElementSetting>() { Description = "" };

        [TypeConverter(typeof(CustomCollectionConverter<ElementSetting>))]
        [RefreshProperties(RefreshProperties.All)]
        [Category("条件")]
        public CustomCollection<ElementSetting> ElementSettings 
        {
            get { return _elementSettings; }
            //set; 
        }

        [Category("描述")]
        public string Memo { get; set; }

        #region PropertyData impl
        public string GetDisplayName()
        {
            return "Conditinon";
        }
        public string GetDescription()
        {
            return "description";
        }
        public string GetValue()
        {
            return Memo;
        }
        #endregion
    }
}